#include<stdio.h>
#include<stdlib.h>
#include<time.h>



int main(void){
    FILE*fp = fopen("./a.c","w+");
    if(fp == NULL){
        printf("fopen err\n");
        return -1;
    }

    printf("fopen success\n");
    fputc('a',fp);
    fputc('b',fp);

    char ch =fgetc(fp);

    if(ferror(fp)){
        perror("err");
    }else if(feof(fp)){
        printf("end of file\n");
        printf("%c\n",ch);
    }

    fclose(fp);

    return 0;
}